package com.qfedu.labsystem.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName RabbitMQConfig
 * @Author ykx
 * @Date 2024/4/12 14:04
 * @Version 1.0
 */
@Configuration
public class RabbitMQConfig {
    //1. 创建exchange - topic
    @Bean
    public TopicExchange getTopicExchange() {
        return new TopicExchange("boot-topic-exchange", true, false);
    }


    //2. 创建queue
    @Bean
    public Queue getQueue() {
        return new Queue("boot-queue", true, false, false, null);
    }


    //3. 绑定在一起
    @Bean
    public Binding getBinding(TopicExchange topicExchange, Queue queue) {
        return BindingBuilder.bind(queue).to(topicExchange).with("*.red.*");
    }
}
